package com.zengzhi.mydesignmode.garnishermode.twodemo;

/**
 * @author xiejiawei
 * @Date 2021-08-23
 * @Time 21:45
 * 饮料超级类
 */
public abstract class Beverage {


    public void setDescription(String description) {
        this.description = this.description += "," + description;
    }

    String description;
    double milk;
    double soy;
    double mocha;
    double whip;

    public double getMilk() {
        return milk;
    }

    public boolean hasMilk() {
        return this.milk != 0.0;
    }

    public void setMilk(double milk) {
        this.milk = milk;
    }

    public double getSoy() {
        return soy;
    }

    public void setSoy(double soy) {
        this.soy = soy;
    }
    public boolean hasSoy() {
        return this.soy != 0.0;
    }

    public double getMocha() {
        return mocha;
    }

    public void setMocha(double mocha) {
        this.mocha = mocha;
    }
    public boolean hasMocha() {
        return this.mocha != 0.0;
    }

    public double getWhip() {
        return whip;
    }

    public void setWhip(double whip) {
        this.whip = whip;
    }
    public boolean hasWhip() {
        return this.whip != 0.0;
    }

    public String getDescription() {
        return description;
    }

    public double cost(){
        double total = 0.0;
        if(hasMilk()){
            total += getMilk();
        }
        if(hasMocha()){
            total += getMocha();
        }
        if(hasSoy()){
            total += getSoy();
        }
        if(hasWhip()){
            total += getWhip();
        }
        return total;
    };
}
